import { createStore } from 'vuex';
import createPersistedState from 'vuex-persistedstate';
/**
 * @description vuex我配了一个持久化插件，会同步sessionStorage，不用手动存了，别的跟正常用法一样，如果状态过多，就按功能分module
 * @author 王冰
 * @date 2024/09/26 17:56
 */
export default createStore({
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
    }),
  ],
  state: {
    haha: '',
  },
  getters: {},
  mutations: {
    handleHaha(state, payload) {
      state.haha = payload;
    },
  },
  actions: {
    HAHA({ commit }, payload) {
      commit('handleHaha', payload);
    },
  },
  modules: {},
});
